package com.ks.member.controller;


import com.ks.core.base._ControllerBase;
import com.ks.core.core.Result;
import com.ks.core.dto.SearchCriteriaBase;
import com.ks.member.aop.Author;
import com.ks.member.controller.dto.Certification;
import com.ks.member.controller.dto.MemberRequest;
import com.ks.member.entity.MemberRealname;
import com.ks.member.service.IMemberRealNameService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 * 会员-实名申请单 前端控制器
 * </p>
 *
 * @author kingdee123
 * @since 2020-12-21
 */
@RestController
@RequestMapping("/memberRealName")
@ApiOperation(value = "微会员服务管理模块", notes = "微会员服务管理模块")
public class MemberRealNameController extends _ControllerBase {
    @Autowired
    private IMemberRealNameService iMemberRealNameService;
    @PostMapping("/selectRealName")
    @ApiOperation(value = "实名认证清单查询接口",notes = "实名认证清单查询接口")
    @Author
    public Object selectRealName(@RequestBody SearchCriteriaBase searchCriteriaBase){
        Map<String, Object> resultMap = iMemberRealNameService.selectMemberRealName(getContext(),searchCriteriaBase);
        return Result.success(resultMap);
    }

    @PostMapping("/selectAdminRealName")
    @ApiOperation(value = "系统管理实名认证清单查询接口",notes = "系统管理实名认证清单查询接口")
    public Object selectAdminRealName(@RequestBody SearchCriteriaBase searchCriteriaBase){
        Map<String, Object> resultMap = iMemberRealNameService.selectAdminMemberRealName(getContext(),searchCriteriaBase);
        return Result.success(resultMap);
    }


    @PostMapping("/commitCertification")
    @ApiOperation(value = "提交实名认证接口",notes = "通过上传realName，personID，idCardA，idCardB来进行实名注册")
    @Author
    public Object commitCertification(@RequestBody MemberRealname realname){
        int i = iMemberRealNameService.commitCertification(getContext(),realname);
        return Result.success(i);
    }
    @PostMapping("/certificationApprove")
    @ApiOperation(value = "提交实名认证审核接口",notes = "传递id,checkResult，改变审核状态")
    @Author
    public Object certificationAudit(@RequestBody MemberRequest request){
        int i = iMemberRealNameService.certificationAudit(getContext(),request.getId(),request.getState(),request.getName(),request.getRemark());
        return Result.success(i);
    }
}

